<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .father{
            background-color: pink;
            width: 200px;
            height: 200px;
        }
        .son{
            position: absolute;
            background-color: red;
            margin-left: 50px;
            margin-top: 50px;
            width: 100px;
            height: 100px;
        }
        
    </style>
</head>
<body>
    <div class="father">
        <div class="son">

        </div>
    </div>
    <script>
        var father = document.querySelector('.father');
        var son = document.querySelector('.son');
        //捕获阶段
        son.addEventListener('click',function(){
                alert('son');
        },true)
            
        father.addEventListener('click',function(){
                alert('father');
        },true)//点击father的时候只弹出father，因为father第一个就被捕获了
            
        //冒泡阶段
        father.addEventListener('click',function(){
            alert('father');
        },false)
        son.addEventListener('click',function(e){
            alert('son');
            e.stopPropagation();
        })
    </script>
</body>
</html>